name: Build Native Image

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Cache Maven dependencies
      uses: actions/cache@v2
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-

    - name: Setup GraalVM
      uses: graalvm/setup-graalvm@v1
      with:
        java-version: '21.0.2'
        distribution: 'graalvm'
        github-token: ${{ secrets.GITHUB_TOKEN }}

    - name: Build Native Image
      run: |
        ./mvnw package -Pnative -Pproduction native:compile
